import React, { FC, useEffect, useState, useRef } from 'react';
import { Descriptions, Button } from 'antd';
import '../../static/css/administrator/Admdetail.css';
import { useNavigate } from 'react-router-dom';
import { useParams } from 'react-router';
import { getDetail } from '../../apis/administrator'
import '../../static/css/administrator/admAdd.css'
import { Form, Input, Radio, RadioChangeEvent, Switch, message } from 'antd';
const Admdetail: FC<any> = (props: any): JSX.Element => {
  const { id } = useParams();
  console.log(id);
  let [list, setList] = useState({})
  const ss = async () => {
    const res: any = await getDetail(Number(id))
    console.log(res);
    if (res.code === '00000') {
      setList(res.data)
      console.log(res.data);
      console.log(list);
    }
    console.log(list);
    console.log(res.data);


  }

  const navigate = useNavigate();
  // const admList = () => {
  //   navigate(`/index/administrator`)
  // }

  useEffect(() => {
    ss()
    getData()
  }, [id])

  const addList = ()=>{
    navigate(`/index/administrator`)
  }


  const formRef: any = useRef()
  const getData = async () => {
    const res: any = await getDetail(Number(id))
    console.log(res);
    formRef.current.setFieldsValue(res.data)
  }

  return (
    <div>




      < Form
        ref={formRef}
        labelCol={{ span: 5 }
        }
        wrapperCol={{ span: 14 }}
        layout="horizontal" >
        <Form.Item name="admin_name" label="管理员名称" rules={[{ required: true }]}>
          <Input style={{ border: "none" }}  />
        </Form.Item>
        <Form.Item name="real_name" label="真实姓名">
          <Input style={{ border: "none" }}/>
        </Form.Item>
        <Form.Item name="email" label="邮箱">
          <Input style={{ border: "none" }} />
        </Form.Item>
        <Form.Item name="admin_name" label="部门" >
          <Input style={{ border: "none" }}  />
        </Form.Item>
        <Form.Item name="mobile" label="手机号" >
          <Input style={{ border: "none" }}  />
        </Form.Item>
        <Form.Item name="role" label="角色" >
          <Radio.Group>
            <Radio value={2}>经管负责人</Radio>
            <Radio value={1}>部门负责人</Radio>
          </Radio.Group>
          {/* <Radio.Group options={plainOptions} onChange={onChange1} value={value1} /> */}
          {/* <Radio value={1} >经管负责人</Radio> */}
          {/* <Radio value={2}>经管负责人</Radio> */}
        </Form.Item>
        <Form.Item name="pwd" label="管理员密码" >
          <Input style={{ border: "none" }} />
        </Form.Item>
        <Form.Item name="is_use" valuePropName="checked" label="是否启用" >
          <Switch />
        </Form.Item>
        <Form.Item name="repwd" label="确认密码" >
          <Input style={{ border: "none" }} />
        </Form.Item>
        <Form.Item name="remarks" label="备注" >
          <Input style={{ border: "none" }}  />
        </Form.Item>
        <Form.Item>
        </Form.Item>
        <Form.Item>
          <div className='but'>
            <Button onClick={addList} type="primary" htmlType="submit" size='middle'>
              返回
            </Button>
          </div>
        </Form.Item>
      </Form >
    </div >
  )
}
export default Admdetail